package cn.wolfcode.luowowo.flight.domain;

import cn.wolfcode.luowowo.common.domain.BaseDomain;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

@Getter
@Setter
public class Flight extends BaseDomain {

    public static final Integer STATE_HOT = 1; //热门
    public static final Integer STATE_NORMAL = 0; //普通

    //城市
    private String name;
    //城市编码
    private String aircode;
    //热门:默认值普通
    private Integer hot = STATE_NORMAL;
    //首字母
    private String initial;
    //出发机场
    private String arrPort;
    //到达机场
    private String depPort;
    //出发时间
    private Date arrTime;
    //到达时间
    private Date depTime;
    //出发航班
    private String flightNo;
    //航空名
    private String flightName;
    //出发城市
    private String orgCity;
    //到达城市
    private String dstCity;
    //价格
    private BigDecimal price;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date time;
    public String getHref() {
        return "/flight/showdian?tid=" + super.id;
    }

    public String getArrDate() {
        String str = "HH:mm";
        SimpleDateFormat sdf = new SimpleDateFormat(str);
        return sdf.format(this.arrTime);
    }
    public String getDepDate() {
        String str = "HH:mm";
        SimpleDateFormat sdf = new SimpleDateFormat(str);
        return sdf.format(this.depTime);
    }
}
